#include "CoCoA/library.H"
using namespace CoCoA;
using namespace std;

void program()
{
  GlobalManager CoCoAFoundations;
  const	int Nvars=1;
  SparsePolyRing P = NewPolyRing(RingQ(), Nvars); // QQ[x,y];
  const vector<RingElem>& x = indets(P);
  RingElem f = power(x[0],6) - 1; // f = x^96-y^96
  RingElem g = power(x[0],3) - 2; // f = x^96-y^96
  // FacInfo contains 3 fields:
  //   myFactors         - a vector of irreducible factors
  //   myExponents       - a vector of the corresponding multiplicities
  //   myRemainingFactor - an unfactored part (e.g. the content)

  GlobalOutput() << "The addition is " << f + g <<  endl;
  GlobalOutput() << "The substraction is " << f - g <<  endl;
  GlobalOutput() << "The division is " << f / g <<  endl;
}

int main()
{
  try
  {
    program();
    return 0;
  }
  catch (const CoCoA::ErrorInfo& err)
  {
    GlobalErrput() << "***ERROR***  UNCAUGHT CoCoA error";
    ANNOUNCE(err);
  }
  catch (const std::exception& exc)
  {
    GlobalErrput() << "***ERROR***  UNCAUGHT std::exception: " << exc.what() << endl;
  }
  catch(...)
  {
    GlobalErrput() << "***ERROR***  UNCAUGHT UNKNOWN EXCEPTION" << endl;
  }
  return 1;
}

//----------------------------------------------------------------------
// RCS header/log in the next few lines
// $Header: /Volumes/Home_1/cocoa/cvs-repository/CoCoALib-0.99/examples/ex-factor1.C,v 1.1 2009/09/23 14:09:36 abbott Exp $
// $Log: ex-factor1.C,v $
// Revision 1.1  2009/09/23 14:09:36  abbott
// First example for (polynomial) factorization.
//
//

